//
//  ViewController.m
//  liveDemo
//
//  Created by 许盛杰 on 2022/9/14.
//

#import "ViewController.h"

#import "PlayLiveViewController.h"
#import "RecordingViewController.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate,UITextViewDelegate>
@property (nonatomic, strong) UITableView             *tableView;
 
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"直播模块";
    [self initUI];
    
    // Do any additional setup after loading the view.
}
- (void)initUI {
  
    self.view.backgroundColor = [UIColor blueColor];

    [self.view addSubview:self.tableView];

}

- (UITableView *)tableView {
      if (!_tableView) {
      _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
      _tableView.backgroundColor = [UIColor whiteColor];
      _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
      _tableView.showsVerticalScrollIndicator = NO;
      _tableView.delegate = self;
      _tableView.dataSource = self;
      }
     return _tableView;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}
#pragma mark 设置cell每行的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 1) {
        return 280;
    }
    return 80;
}




- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (!cell)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cell"];
    }
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, self.view.frame.size.width -150, 80)];
    label.textColor = [UIColor redColor];
    label.textAlignment = NSTextAlignmentLeft;
    label.numberOfLines = 0;
    [cell.contentView addSubview:label];
    if (indexPath.row == 0) {
        label.text = @"1、录制直播（推流）";
    }
    if (indexPath.row == 1) {
        label.text = @"2、播放观看（拉流）";
    }
    
    UIView *xian = [[UIView alloc]initWithFrame:CGRectMake(20, 79, self.view.frame.size.width, 1)];
    xian.backgroundColor = [UIColor colorWithRed:240.0/255 green:240.0/255 blue:240.0/255 alpha:1];
    [cell.contentView addSubview:xian];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 0) {
        RecordingViewController *vc = [[RecordingViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    if (indexPath.row == 1) {
        PlayLiveViewController *vc = [[PlayLiveViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end


